#include <iostream>
#include "bzlib.h"

int main() {
    char* originData = nullptr;
    unsigned int originDataSize = 0;
    char* compressedDst = nullptr;
    unsigned int compressedLenght;
    int result = BZ2_bzBuffToBuffCompress(compressedDst, &compressedLenght, originData,
        originDataSize, 5, 0, 30);

    bool success = false;
    if (BZ_CONFIG_ERROR == result)  // if
    {
        std::cout << "the library has been mis-compiled" << std::endl;
    }
    else if (BZ_PARAM_ERROR == result)  // if
    {
        std::cout << "dest is NULL or destLen is NULL or blockSize100k<1 or blockSize100k> 9 or "
            "verbosity<0 or verbosity> 4 or workFactor<0 or workFactor> 250"
            << std::endl;
    }
    else if (BZ_MEM_ERROR == result)  // if
    {
        std::cout << "insufficient memory is available" << std::endl;
    }
    else if (BZ_OUTBUFF_FULL == result)  // if
    {
        std::cout << "the size of the compressed data exceeds *destLen" << std::endl;
    }
    else if (BZ_OK == result)
    {
        success = true;

        //std::cout << "Compress data consuming time: " << duration << "s." << std::endl;
        std::cout << "Origin size = " << originDataSize << "; Compressed size = " << compressedLenght
            << "; Compress ratio: " << double(compressedLenght) * 100.0 / originDataSize << "%."
            << std::endl;
    }

    std::cout << "Hello world!" << std::endl;
    return 0;
}
